@extends('layouts.console_header')

@section('title', '商家已提现列表')

@section('resources')
    @parent
    <style>
        nav{height: 50px;line-height: 50px;}
        nav a,nav span{margin-left: 20px;}
        nav input{margin-left: 20px;height: 28px;border: 1px solid #000;margin-top: 10px;}
    </style>
@endsection

@section('content')
<!--  html内容  -->
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;">
		    <span style="color: #7f7f7f;"><a href="/console/index">首页</a>>财务中心></span>
		    <span class="co_violet">商家已提现列表</span>
        </p>
		<a href="#" onclick="export_data()"><p class="fr tc back_btn">导出</p></a>
	</div>
    <nav>
        <a class="fl" href="/console/finance/gotmoney/list?cityid={{$cityid}}&type=today">今日</a>
        <a class="fl" href="/console/finance/gotmoney/list?cityid={{$cityid}}&type=yesterday">昨日</a>
        <a class="fl" href="/console/finance/gotmoney/list?cityid={{$cityid}}&type=week">本周</a>
        <a class="fl" href="/console/finance/gotmoney/list?cityid={{$cityid}}&type=thismonth">本月</a>
        <a class="fl" href="/console/finance/gotmoney/list?cityid={{$cityid}}&type=lastmonth">上月</a>
        <a class="fl" href="/console/finance/gotmoney/list?cityid={{$cityid}}&type=all">全部</a>
        <span class="fl">时段选择</span>
        <input class="fl" type="date" name="starttime" value="{{date('Y-m-d', strtotime($starttime))}}" onchange="select_date()">
        <span class="fl">至</span>
        <input class="fl" type="date" name="lasttime" value="{{date('Y-m-d', strtotime($lasttime))}}" onchange="select_date()">
    </nav>

	<table class="finance_top_list">
		<tr>
			<th>已提现商家</th>
			<th>已提现金额(元)</th>
		</tr>
		<tr>
			<td>{{$shopnum}}</td>
			<td>{{$shopamount}}</td>
		</tr>
	</table>
	<table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>序号</th>
                <th>商家代码</th>
                <th>商家名称</th>
                <th>持卡人</th>
                <th>银行卡号</th>
                <th>银行名称</th>
                <th>开户行所在地</th>
                <th>开户行行名称</th>
                <th>提现日</th>
                <th>提现金额(元)</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>序号</th>
                <th>商家代码</th>
                <th>商家名称</th>
                <th>持卡人</th>
                <th>银行卡号</th>
                <th>银行名称</th>
                <th>开户行所在地</th>
                <th>开户行名称</th>
                <th>提现日</th>
                <th>提现金额(元)</th>
            </tr>
        </tfoot>
        <tbody>
        @foreach($data as $list)
            <tr>
            @if(!isset($i))
                <td>{{$i=1}}</td>
            @else
                <td>{{++$i}}</td>
            @endif
                <td>{{$list['shopcode']}}</td>
                <td>{{$list['shopname']}}</td>
                <td>{{$list['cardholder']}}</td>
                <td>{{$list['bankcard']}}</td>
                <td>{{$list['bankname']}}</td>
                <td>{{$list['bankprovince'] . $list['bankcity']}}</td>
                <td>{{$list['opencardbank']}}</td>
                <td>{{date('Y-m-d H:i:s', strtotime($list['accounttime']))}}</td>
                <td>{{$list['accountamount']}}</td>
            </tr>
        @endforeach
        </tbody>
    </table>
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
        var cityid='{{$cityid}}';
        var str = window.location.href;
        if(str.indexOf("today") > 0){
            $("nav a").eq(0).css({"color": "#9955c6"});
        }else if(str.indexOf("yesterday") > 0){
            $("nav a").eq(1).css({"color": "#9955c6"});
        }else if(str.indexOf("week") > 0){
            $("nav a").eq(2).css({"color": "#9955c6"});
        }else if(str.indexOf("thismonth") > 0){
            $("nav a").eq(3).css({"color": "#9955c6"});
        }else if(str.indexOf("lastmonth") > 0){
            $("nav a").eq(4).css({"color": "#9955c6"});
        }else if(str.indexOf("all") > 0){
            $("nav a").eq(5).css({"color": "#9955c6"});
        }
        function select_date() {
            var startTime = $("input[name='starttime']").val();
            var lastTime = $("input[name='lasttime']").val();
            if(!startTime || !lastTime) {
                alert('请选择开始时间和结束时间'); return;
            }
            window.location.href="/console/finance/gotmoney/list?cityid=" + cityid+"&starttime="+startTime+"&lasttime="+lastTime;
        }
        function export_data() {
            var startTime = $("input[name='starttime']").val();
            var lastTime = $("input[name='lasttime']").val();
            if(!startTime || !lastTime) {
                alert('请选择开始时间和结束时间'); return;
            }
            window.open("/console/finance/gotmoney/export?cityid="+cityid+"&starttime="+startTime+"&lasttime="+lastTime, '_blank');
        }
    </script>
@endsection